﻿using AutoMapper;
using SIG.DAL.Dapper.Model;
using SIG.DAL.Dapper.Repositories;
using SIG.Model.Case;
using SIG.Service.Case;
using SIG.ViewModel.Front.Clients;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace SIG.WebMVC.Controllers
{
    public class ClientController : Controller
    {
      
        private readonly ClientRepository _clientService;
        private readonly PageMetaRepository _pageMetaService;
        private IMapper _mapper;
        public ClientController( IMapper mapper)
        {         
            _clientService = new ClientRepository();
            _pageMetaService = new PageMetaRepository();
            _mapper = mapper;
        }
        // GET: Client
        public ActionResult Index()
        {
            var vm = _clientService.GetActiveItems();
            var url = Request.RawUrl;
            ViewBag.PageMeta = _pageMetaService.GetPageMeta(ModelType.MENU, url);
            return View(vm);
        }

        public ActionResult GetClientForHome()
        {
            var list = _clientService.GetActiveItems().Where(m=>!string.IsNullOrEmpty(m.LogoURL)).Take(12); 
            return PartialView("_GetClientForHome", list);
        }
    }
}